<!doctype html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Document</title>
    </head>
    <body>
        <div>postMessage2</div>
        <script>
            // 接收domain1的数据
            window.addEventListener(
                'message',
                function (e) {
                    console.log('data from domain1 ---> ' + e.data)
                    var data = JSON.parse(e.data)
                    if (data) {
                        data.number = 16
                        // 处理后再发回domain1
                        window.parent.postMessage(JSON.stringify(data), 'http://127.0.0.1:8080/3.postMessage1.html')
                    }
                },
                false
            )
        </script>
    </body>
</html>
